package com.hyt.it.ogt.ks.util;

import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
 
public class HttpClientUtil {
 
	/**
	 * 带参数的get请求
	 * @param url
	 * @param param
	 * @return String
	 */
	public static String doGet(String url, Map<String, String> param) {
		// 创建Httpclient对象
		CloseableHttpClient httpclient = HttpClients.createDefault();
 
		String resultString = "";
		CloseableHttpResponse response = null;
		try {
			// 创建uri
			URIBuilder builder = new URIBuilder(url);
			if (param != null) {
				for (String key : param.keySet()) {
					builder.addParameter(key, param.get(key));
				}
			}
			URI uri = builder.build();
			// 创建http GET请求
			HttpGet httpGet = new HttpGet(uri);
			// 执行请求
			response = httpclient.execute(httpGet);
			// 判断返回状态是否为200
			if (response.getStatusLine().getStatusCode() == 200) {
				resultString = EntityUtils.toString(response.getEntity(), "UTF-8");
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (response != null) {
					response.close();
				}
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return resultString;
	}
	
	/**
	 * 不带参数的get请求
	 * @param url
	 * @return String
	 */
	public static String doGet(String url) {
		return doGet(url, null);
	}
 
	/**
	 * 带参数的post请求
	 * @param url
	 * @param param
	 * @return String
	 */
	public static String doPost(String url, Map<String, String> param) {
		// 创建Httpclient对象
		CloseableHttpClient httpClient = HttpClients.createDefault();
		CloseableHttpResponse response = null;
		String resultString = "";
		try {
			// 创建Http Post请求
			HttpPost httpPost = new HttpPost(url);
			// 创建参数列表
			if (param != null) {
				List<NameValuePair> paramList = new ArrayList<>();
				for (String key : param.keySet()) {
					paramList.add(new BasicNameValuePair(key, param.get(key)));
				}
				// 模拟表单
				UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList);
				httpPost.setEntity(entity);
			}
			// 执行http请求
			response = httpClient.execute(httpPost);
			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				response.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return resultString;
	}
 
	/**
	 * 不带参数的post请求
	 * @param url
	 * @return String
	 */
	public static String doPost(String url) {
		return doPost(url, null);
	}
	
	/**
	 * 传送json类型的post请求
	 * @param url
	 * @param json
	 * @param token
	 * @return String
	 */
	public static String doPostJson(String url, String json) {
		return doPostJson(url, json, "");
	}
	
	/**
	 * 传送json类型的post请求
	 * @param url
	 * @param json
	 * @param token
	 * @return String
	 */
	public static String doPostJson(String url, String json, String token) {		
		
		CloseableHttpClient httpClient = HttpClients.createDefault();
		CloseableHttpResponse response = null;
/*
		json = "{\n" +
				"  \"results\": [{\"questionId\":\"61\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"62\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"63\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"64\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"65\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"66\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"67\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"68\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"69\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"70\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"71\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"72\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"73\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"74\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"75\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"76\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"77\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"78\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"79\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"80\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"81\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"82\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"83\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"84\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"85\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"86\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"87\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"88\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"89\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"90\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"91\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"92\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"93\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"94\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"95\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"96\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"97\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"98\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"99\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"100\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"101\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"102\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"103\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"104\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"105\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"106\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"107\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"108\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"109\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"110\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"111\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"112\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"113\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"114\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"115\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"116\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"117\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"118\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"119\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"120\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"121\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"122\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"123\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"124\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"125\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"126\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"127\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"128\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"129\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"130\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"131\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"132\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"133\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"134\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"135\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"136\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"137\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"138\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"139\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"140\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"141\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"142\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"143\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"144\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"145\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"146\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"147\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"148\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"149\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"150\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"151\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"152\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"153\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"154\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"155\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"156\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"157\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"158\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"159\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"160\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"161\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"162\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"163\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"164\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"165\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"166\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"167\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"168\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"169\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"170\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"171\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"172\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"173\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"174\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"175\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"176\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"177\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"178\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"179\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"180\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"181\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"182\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"183\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"184\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"185\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"186\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"187\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"188\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"189\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"190\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"191\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"192\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"193\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"194\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"195\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"196\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"197\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"198\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"199\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"200\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"201\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"202\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"203\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"204\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"205\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"206\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"207\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"208\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"209\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"210\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"211\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"212\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"213\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"214\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"215\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"216\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"217\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"218\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"219\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"220\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"221\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"222\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"223\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"224\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"225\",\"questionBankId\":\"8\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"226\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"227\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"228\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"229\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"230\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"231\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"232\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"233\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"234\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"235\",\"questionBankId\":\"6\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"236\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"237\",\"questionBankId\":\"11\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"238\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"239\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"240\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"241\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"242\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"243\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"244\",\"questionBankId\":\"10\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"245\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"246\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"247\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"248\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"249\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"250\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"251\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"252\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"253\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"254\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"255\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"256\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"257\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"258\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"259\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"260\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"261\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"262\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"263\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null},{\"questionId\":\"264\",\"questionBankId\":\"9\",\"questionGroupId\":\"5\",\"option\":\"A\",\"disturbOption\":null}],\n" +
				"  \"userInfo\": {\"birthday\":\"1999-08-11\",\"specialty\":\"金融学\",\"education\":\"本科\",\"gender\":1,\"collage\":\"中国人民大学\",\"examDate\":\"2021-6-9\",\"graduationDate\":\"2021-7-8\",\"name\":\"董晓宇\",\"nativePlace\":\"福建\"}\n" +
				"}";
				*/
		String resultString = "";		
		try {
			// 创建Http Post请求
			HttpPost httpPost = new HttpPost(url);
			if (!"".equals(token)) {
				 httpPost.setHeader("Authorization",token);
			}
			// 创建请求内容
			StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
			httpPost.setEntity(entity);
			// 执行http请求
			response = httpClient.execute(httpPost);
			resultString = EntityUtils.toString(response.getEntity(), "utf-8");
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				response.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}		
		return resultString;
	}
}




